<template>
  <div>
    <breadcrumb></breadcrumb>
    <!-- 分割线 -->
    <el-divider content-position="left">修改商品</el-divider>
    <proform :rows= form :protype="2" @operation="operation"></proform>
  </div>
</template>

<script>
import breadcrumb from "../components/breadcrumb.vue";
import proform from "./components/proform.vue";
import httpApi from '@/http';
export default {
    components: { breadcrumb,proform},
      data(){
          return{
              id:this.$route.params.id,
              // 表单内容
              form:{
              // type:this.$store.state.utype,
              // shore_id:this.$store.state.uid,
              westerndetail_id:'',
              title:'',
              type_id:'',
              isNew:'',
              explains:'',
              // img1:'',
              // img2:'',
              // img3:'',
              // img4:'',
              // img5:''
            },
          }
      },
      methods: {
        //子组件传递的事件在标签上接收之后可以在methods中直接调用
        //并可以拿到子组件的传递的参数index和rows
        operation(rows) {
          console.log(rows,'值')
          httpApi.proApi.queryProRevise(rows).then(res=>{
            //  console.log(res,'添加');
            if(res.data.code === 200 && res.data.msg === 'ok'){
              this.$message({
                message: '恭喜你，修改商品成功',
                type: 'success'
              });
              this.$router.push('/home/pro-list')
            }else{
              this.$message({
                showClose: true,
                message: '修改商品失败',
                type: 'error'
              });
            }
          })
        },

        detailslist(){
              httpApi.proApi.queryProById({westerndetail_id:this.id}).then(res =>{
                  console.log("详情",res);
                  this.form.explains = res.data.results[0].explains
                  this.form.img1 = res.data.results[0].img1
                  this.form.isNew = res.data.results[0].isNew
                  this.form.title =  res.data.results[0].title
                  this.form.type_id =  res.data.results[0].type_id  
                  this.form.westerndetail_id = res.data.results[0].westerndetail_id    
              })

          },
      },

      mounted(){
        this.detailslist()
      },
}
</script>

<style lang="scss" scoped>
// .el-form-item {

// display: inline-block !important;

// }
</style>